package utils

import java.awt.Image
import java.awt.image.BufferedImage

object ImageUtils {
    fun compressImage(rawImage : BufferedImage,factor : Int) : BufferedImage
    {
        val width = rawImage.width / factor
        val height = rawImage.height / factor
        val compressedImage = rawImage.getScaledInstance(width,height, Image.SCALE_SMOOTH)
        val image = BufferedImage(width,height,BufferedImage.TYPE_INT_RGB)
        val graphic = image.graphics
        graphic.drawImage(compressedImage,0,0,null)
        graphic.dispose()
        return image
    }
}